/*   
 * �ļ�����FinanceDao.java
 * ��Ȩ����Copy Ruantu��  
 * ��������������  
 * �޸��ˣ���MengFanding�� 
 * �޸�ʱ�䣺2017 ����2:24:45
 * �޸ĵ��ţ����޸ĵ��š�  
 * �޸����ݣ����޸����ݡ�  
 */

package com.ruantu.clothing.dao.finance;

import java.util.List;
import java.util.Map;

import com.ruantu.clothing.entity.KeHu;
import com.ruantu.clothing.entity.ZZMX;
import com.ruantu.clothing.entity.report.Foot;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Select;

import com.ruantu.clothing.entity.finance.Finance;
import com.ruantu.clothing.entity.finance.Period;

/**
 * FinanceDao
 */
public interface FinanceMapper {

    @Insert("insert into finance_period (name,starttimestamp) values(#{name},#{starttimestamp})")
    int addNewPeriod(Map<String, Object> map);

    @Result(javaType = Period.class)
    @Select("select * from finance_period where name = #{name} limit 0,1")
    Period findPeriodByName(Map<String, Object> map);

    @Result(javaType = Period.class)
    @Select("select * from finance_period order by id desc")
    List<Period> findAllPeriod();

    @Result(javaType = Period.class)
    @Select("select * from finance_period order by starttimestamp desc limit 0,1")
    Period activePeriod();


    @Result(javaType = Finance.class)
    @Select("SELECT * FROM finance WHERE wldwid = #{wldwid} and jgid = #{jgid} AND periodid = ( SELECT id FROM finance_period ORDER BY starttimestamp DESC LIMIT 0, 1 )")
    Finance findByWldwFinance(Map<String, Object> map);

    @Result(javaType = Finance.class)
    @Select("SELECT * FROM finance WHERE wldwid = #{wldwid} AND jgid = #{jgid} ORDER BY id DESC LIMIT 0, 1")
    Finance findByNearFinance(Map<String, Object> map);

    int deleteByPrimaryKey(String id);

    int insert(Finance record);

    int insertSelective(Finance record);

    Finance selectByPrimaryKey(String id);

    int updateByPrimaryKeySelective(Finance record);

    int updateByPrimaryKey(Finance record);

    List<Finance> findJgPeriodFinance(Map<String, Object> map);

    int findJgPeriodFinanceCount(Map<String, Object> map);

    @Result(javaType = KeHu.class)
    @Select("select id,kehuming wldwName,pifashang.jgid jgId from pifashang union all select id,jgname wldwName ,jg.id jgId from jg union all select id,huiyuanming wldwName,vip.jgid from vip union all select id,gname wldwName,gongyingshang.jg_id jgId from gongyingshang")
    List<KeHu> selectAllKeHu();


    List<Finance> selectZZReportList(Map<String, Object> map);

    List<Finance> selectZZReportListDaoChu(Map<String, Object> map);

    Integer selectZZReportCount(Map<String, Object> map);

    List<ZZMX> selectZZMXReportList(Map<String,Object> map);

    List<ZZMX> selectZZMXReportListDaoChu(Map<String,Object> map);

    Integer  selectZZMXReportCount(Map<String,Object> map);

    List<ZZMX> financeAccount(Map<String,Object> map);

    List<ZZMX> financeAccountReport(Map<String,Object> map);

    Foot financeAccountCount(Map<String,Object> map);





}
